function Main()
	--require 'tolua.reflection'
	--tolua.loadassembly('Assembly-CSharp')
	--tolua.loadassembly('Assembly-CSharp-firstpass')
	require 'config'

	if not IsTest then
		local file_exists = function(name)
			local f=io.open(name,"r")
			if f~=nil then io.close(f) return true else return false end
		end
		IsTest = file_exists(UnityEngine.Application.persistentDataPath .. '/whosyourdaddy')
	end

	--初始化各种Lua结构
	require "Init"
	Init()
	gameMgr:ChangeState("ProcLogin", nil)

	UpdateBeat:Add(function()
		if Application.platform == UnityEngine.RuntimePlatform.Android then
			if Input.GetKeyDown(UnityEngine.KeyCode.Escape) then
				pcall(function()
					VIEWM.CloseCurViewOrQuitGame()
				end)
			end
		elseif Application.platform == UnityEngine.RuntimePlatform.WindowsEditor then
			if Input.GetKeyDown(UnityEngine.KeyCode.F12) then
				pcall(function()
					VIEWM.CloseCurViewOrQuitGame()
				end)
			end
		end
	end)

end

FrameNum = 0
coroutine.start(function()
	while true do
		FrameNum = FrameNum +1
		coroutine.step()
	end
end)


--场景切换通知
function OnLevelWasLoaded(level)
	collectgarbage("collect")
	Time.timeSinceLevelLoad = 0
end

function ForceGC()
	collectgarbage("collect")
end


function reload(moduleName)
	package.loaded[moduleName] = nil
	return require(moduleName)
end

function restart()
	if not ProcRestarting.IsRestarting  then
		gameMgr:ChangeState("ProcRestarting", nil)
	end
end

function CSCall_OnApplicationFocus(focus)

end

function CSCall_OnApplicationPause(pause)

end

function CSCall_OnApplicationQuit()

end

